/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * PanelGestionCitas.java
 *
 * Created on 26/09/2011, 06:31:07 PM
 */

package views;

import javax.swing.JOptionPane;
import javax.swing.JTextField;

/**
 *
 * @author JARR
 */
public class PanelGestionCitas extends javax.swing.JPanel {

    /** Creates new form PanelGestionCitas */
    public PanelGestionCitas() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jLabel5 = new javax.swing.JLabel();
        CTID = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        BDoble = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        jList1 = new javax.swing.JList();

        jLabel5.setFont(new java.awt.Font("Dialog", 1, 14));
        jLabel5.setText("oprima ENTER");

        CTID.setFont(new java.awt.Font("Dialog", 0, 14));
        CTID.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                CTIDFocusGained(evt);
            }
        });
        CTID.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                CTIDKeyPressed(evt);
            }
            public void keyReleased(java.awt.event.KeyEvent evt) {
                CTIDCTKeyReleased(evt);
            }
            public void keyTyped(java.awt.event.KeyEvent evt) {
                CTIDCTKeyTyped(evt);
            }
        });

        jLabel1.setFont(new java.awt.Font("Dialog", 1, 14));
        jLabel1.setText("Digite la ID del consultorio, escoja la transacción que desea hacer y");

        jLabel2.setFont(new java.awt.Font("Dialog", 1, 14));
        jLabel2.setText("ID");

        BDoble.setBackground(new java.awt.Color(0, 0, 51));
        BDoble.setFont(new java.awt.Font("Dialog", 1, 14));
        BDoble.setForeground(new java.awt.Color(204, 204, 204));
        BDoble.setText("jButton1");
        BDoble.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BDobleActionPerformed(evt);
            }
        });

        jList1.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        jScrollPane1.setViewportView(jList1);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(33, 33, 33)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 442, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 557, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                            .addComponent(jLabel2)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(CTID, javax.swing.GroupLayout.PREFERRED_SIZE, 347, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(18, 18, 18)
                            .addComponent(BDoble))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel5)
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(BDoble)
                    .addComponent(CTID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 238, Short.MAX_VALUE)
                .addGap(36, 36, 36))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 600, Short.MAX_VALUE)
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(0, 0, Short.MAX_VALUE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 0, Short.MAX_VALUE)))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 409, Short.MAX_VALUE)
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(0, 9, Short.MAX_VALUE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 10, Short.MAX_VALUE)))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void CTIDFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_CTIDFocusGained
        // String cadena = CTDNI.getText();
        // iniciarPanel();
        // CTDNI.setText(cadena);
        //  CTDNI.selectAll();
}//GEN-LAST:event_CTIDFocusGained

    private void CTIDKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_CTIDKeyPressed
        if (evt.getKeyCode() == 10) {
            //   transaccion();
        }
}//GEN-LAST:event_CTIDKeyPressed

    private void CTIDCTKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_CTIDCTKeyReleased
        JTextField obj = (JTextField) evt.getSource();
        while (!obj.getText().isEmpty() && (obj.getText().charAt(0) < '0' || (int) obj.getText().charAt(0) > '9')) {
            obj.setText(obj.getText().substring(1));
        }
}//GEN-LAST:event_CTIDCTKeyReleased

    private void CTIDCTKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_CTIDCTKeyTyped
        JTextField obj = (JTextField) evt.getSource();
        if (obj.getSelectionStart() == 0 && (evt.getKeyChar() < '1' || evt.getKeyChar() > '9')) {
            evt.consume();
        } else if ((evt.getKeyChar() < '0' || evt.getKeyChar() > '9')) {
            evt.consume();
        } else if (obj.getText().length() >= 12 && obj.getSelectionEnd() - obj.getSelectionStart() <= 0) {
            evt.consume();
        }
}//GEN-LAST:event_CTIDCTKeyTyped

    private void BDobleActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BDobleActionPerformed
        /*if (CTNombre.getText().isEmpty() || CTApellidos.getText().isEmpty()) {
            JOptionPane.showMessageDialog(this, "Ni el nombre ni el apellido del usuario pueden estar en blanco.", "Campos de texto", JOptionPane.WARNING_MESSAGE);
            if (CTNombre.getText().isEmpty()) {
                CTNombre.requestFocus();
            } else {
                CTApellidos.requestFocus();
            }
        } else {
            if (BDoble.getText().equals("Modificar Usuario")) {
                if (CTNuevoDNI.getText().length() < 7) {
                    JOptionPane.showMessageDialog(this, "El DNI del usuario debe ser de mínimo 7 caracteres.", "Campos de texto", JOptionPane.WARNING_MESSAGE);
                    CTNuevoDNI.requestFocus();
                } else {
                    JOptionPane.showMessageDialog(this, Constructores.mu.actualizarUsuario(usuarioSeleccionado, CTNuevoDNI.getText(), CTNombre.getText(), CTApellidos.getText()));
                    CTDNI.requestFocus();
                    FrameMenuPrincipal.setUsuarioEnSesion(Constructores.udao.consultarUsuario(CTNuevoDNI.getText()));
                }

            } else if (BDoble.getText().equals("Agregar Usuario")) {
                Paciente u = new Paciente(CTDNI.getText(), CTNombre.getText(), CTApellidos.getText());
                JOptionPane.showMessageDialog(this, Constructores.mu.agregarUsuario(u));
                CTDNI.requestFocusInWindow();
            }
        }*/
}//GEN-LAST:event_BDobleActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton BDoble;
    private javax.swing.JTextField CTID;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JList jList1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    // End of variables declaration//GEN-END:variables

}
